﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using SRW;
using System.Collections.Generic;
using SRW.BLL;

public partial class system_sjgl_showPaper : System.Web.UI.Page
{
    public string zhuanxiang = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            RepListContent.DataSource = GetProList("选择题");
            RepListContent.DataBind();

            Repeater1.DataSource = GetProList("判断题");
            Repeater1.DataBind();
            zhuanxiang = Request.QueryString["papername"].ToString();
        }

    }
    
    protected void RepListContent_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        //绑定内层的数据
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            Label Label1 = (Label)e.Item.FindControl("Label1");

            RadioButtonList RBL_Content = (RadioButtonList)e.Item.FindControl("RBL_Content");

            //Repeater Repeater1 = (Repeater)e.Item.FindControl("Repeater1");
            //Repeater1.DataSource = SQL.GetDataTable("wtTmNum", "select wtNumber from wtTmNum");
            //Repeater1.DataBind();


            RBL_Content.DataTextField = "wtanname";
            RBL_Content.DataValueField = "wtanname";
            RBL_Content.DataSource = SQL.GetDataTable("wtanswer", "select wtanname from wtanswer where problemID=" + int.Parse(Label1.Text) + "");
            RBL_Content.DataBind();

        }

    }
    protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        //绑定内层的数据
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            Label Label11 = (Label)e.Item.FindControl("Label11");

            RadioButtonList RBL_Content1 = (RadioButtonList)e.Item.FindControl("RBL_Content1");

            //Repeater Repeater1 = (Repeater)e.Item.FindControl("Repeater1");
            //Repeater1.DataSource = SQL.GetDataTable("wtTmNum", "select wtNumber from wtTmNum");
            //Repeater1.DataBind();


            RBL_Content1.DataTextField = "wtanname";
            RBL_Content1.DataValueField = "wtanname";
            RBL_Content1.DataSource = SQL.GetDataTable("wtanswer", "select wtanname from wtanswer where problemID=" + int.Parse(Label11.Text) + "");
            RBL_Content1.DataBind();

        }

    }
    /// <summary>
    /// 返回抽取的题目
    /// </summary>
    /// <param name="ProType"></param>
    /// <returns></returns>
    public List<Wtproblem> GetProList(string ProType)
    {
        string papername = Request.QueryString["papername"].ToString();
        List<string> mProList = bWtpaper.GetPaper("select distinct problemID from wtpaper where papername='" + papername + "'", "problemID");
        List<Wtproblem> results = new List<Wtproblem>();
        for (int i = 0; i < mProList.Count; i++)
        {
            Wtproblem mWtproblem = bWtproblem.select("select * from wtproblem where pkID=" + int.Parse(mProList[i].ToString()) + "");
            if (mWtproblem.wtprotype == ProType)
            {
                results.Add(mWtproblem);
            }
        }
        return results;
    }
}
